#include "expcustom.h"
#include "ui_expcustom.h"
#include<QDate>
#include<QDebug>
#include<QDesktopWidget>
#include<QMessageBox>
//This shows two dateEdit widgets to select custom range for date selection
ExpCustom::ExpCustom(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ExpCustom)
{
    ui->setupUi(this);
     //ui->pushButton->setIcon(QIcon(":/myresources/images/img_arrow.png"));
     //ui->pushButton->setIconSize(QSize(100,30));
    QRect in=QApplication::desktop()->availableGeometry(this);
    ui->scrollArea->setGeometry(0,0,(in.width()),(in.height()));
    ui->label->setFocus();
    int fontSize=10;
    ui->label->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));
    ui->label_from->setFont(QFont( "lucida", (fontSize-2), QFont::Normal, FALSE ));
    ui->label_to->setFont(QFont( "lucida", (fontSize-2), QFont::Normal, FALSE ));
    ui->dateEdit_from->setFont(QFont( "lucida", (fontSize-2), QFont::Normal, FALSE ));
    ui->dateEdit_to->setFont(QFont( "lucida", (fontSize-2), QFont::Normal, FALSE ));
    ui->pushButton->setFont(QFont( "lucida", (fontSize-2), QFont::Normal, FALSE ));
    QAction* backAction = new QAction( tr("Back"), this );
     backAction->setSoftKeyRole( QAction::NegativeSoftKey );
     connect(backAction, SIGNAL(triggered()), this, SLOT(back()));
     addAction( backAction );
     ui->dateEdit_from->setDate(QDate::currentDate());
     ui->dateEdit_to->setDate(QDate::currentDate());

}

ExpCustom::~ExpCustom()
{
    delete ui;
}
void ExpCustom::back()
{
    (new ExpView)->show();
}

void ExpCustom::on_pushButton_clicked()
{
    if(ui->dateEdit_from->date().operator >=(ui->dateEdit_to->date()))
    {
        QMessageBox::warning(0,"Error !","Please select valid range");
    }
    else
        (new ExpRange(ui->dateEdit_from->date(),ui->dateEdit_to->date()))->show();
}
